<template>
  <div class="app-container">
    <!-- 标题栏 -->
    <div class="title-bar">
      <div class="logo-area">
        <img :src="logo" alt="Logo" class="logo" />
        <span class="app-title">VPNConnect</span>
      </div>
      <div class="window-controls">
        <button class="control-btn minimize" @click="handleMinimize">—</button>
        <button class="control-btn close" @click="handleClose">×</button>
      </div>
    </div>

    <a-layout class="main-layout">
      <a-layout>
        <!-- 左侧信息显示区域 -->
        <a-layout-content class="layout-content">
          <ConnectDetails v-model:selectedConnectionId="selectedConnectionId"></ConnectDetails>
        </a-layout-content>
        
        <!-- 右侧连接列表 -->
        <a-layout-sider class="layout-sider" :width="300">
          <Connects v-model:selectedConnectionId="selectedConnectionId"></Connects>
        </a-layout-sider>
      </a-layout>
    </a-layout>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue';
import Connects from '../components/connects.vue';
import ConnectDetails from '../components/details.vue';
import logo from 'assets/logo.png';
import { Window,Events } from '@wailsio/runtime';

const selectedConnectionId = ref<number|undefined>(undefined);

const connectionStatus = ref(false);

const handleMinimize = () => {
  Events.Emit({
    name: 'customEvent.windows.Onhide',
    data: {
      message: 'hide',
    },
  })
};

const handleClose = () => {
  Window.Close();
};

</script>

<style scoped lang="less">
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.title-bar {
  height: 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
  -webkit-app-region: drag; // 使标题栏可拖动（Electron特性）
}

.logo-area {
  display: flex;
  align-items: center;
  -webkit-app-region: drag;
}

.logo {
  height: 24px;
  width: 24px;
  margin-right: 8px;
}

.app-title {
  font-size: 14px;
  font-weight: bold;
}

.window-controls {
  display: flex;
  -webkit-app-region: no-drag; // 按钮区域不可拖动
}

.control-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  font-size: 16px;
  border-radius: 4px;
  margin-left: 4px;

  &:hover {
    background-color: rgba(0, 0, 0, 0.1);
  }

  &.minimize:hover {
    background-color: rgba(0, 0, 0, 0.1);
  }

  &.close:hover {
    color: rgb(255, 0, 0);
  }
}

.main-layout {
  height: calc(100vh - 40px); // 减去标题栏高度
}

.layout-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background-color: #f9fbfd;
  padding: 20px;
}

.layout-sider {
  height: 100%;
  overflow: hidden;
  border-left: 1px solid #e9e9e9;
  background-color: #fff;
}




// 去除布局组件的默认样式
:deep(.arco-layout) {
  background: transparent;
}

:deep(.arco-layout-sider) {
  background: transparent;
}

:deep(.arco-layout-content) {
  background: transparent;
}
</style>